package com.asset.salesforce.dao;

import java.util.Iterator;
import java.util.List;

import com.asset.salesforce.domain.InvoiceInvoiceTax;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

@Repository
public class InvoiceInvoiceTaxDaoImpl extends BasicDaoImpl<InvoiceInvoiceTax>{
public List<String> getEachTaxSum(Integer id) {
	Session session = sessionFactory.getCurrentSession();
	String queryStatement = "select distinct tax.invoiceTax.name, sum(tax.number) from InvoiceInvoiceTax tax group by tax.invoice.id, tax.invoiceTax.id, tax.invoiceTax.name having tax.invoice.id=:id";
	Query query = session.createQuery(queryStatement);
	query.setParameter("id", id);
	List<String> l =query.list();
    System.out.println("Total Number Of Records : "+l.size());
    @SuppressWarnings("rawtypes")
	Iterator it = l.iterator();
    
    while(it.hasNext())
    {
        Object o[] = (Object[])it.next();
        System.out.println("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb Tax id : "+o[0]+ "bbbbbbbbbbbbbb Tax number : "+o[1]);
        System.out.println("--------------------------------------------------------------------------------------------------");
    }
	return l;
}
}
